<?php

namespace App\Http\Controllers\Admin;

use App\Http\Model\Category;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

class CategoryController extends CommonController
{
    //
    public function index(){
        //get来的admin/category,显示全部分类列表
        $categories = Category::getAllTree();
//        $categories = $this->getTree($categories);
//        dd($categories);
        return view('admin.category.index')->with('data',$categories);
    }

    public function changeorder(){
        $input = Input::all();
        $cate = Category::find($input['cate_id']);
        $cate->cate_order = $input['cate_order'];
        $re = $cate->update();
        if ($re){
            $data = [
                'status'=>200,
                'msg'=>'排序修改成功!'
            ];
        }else{
            $data = [
                'status'=>300,
                'msg'=>'排序修改失败!'
            ];
        }
        return $data;
    }


    public function store(){
        //post来的admin/category
        return 'store';
    }

    public function create(){
        //get来的admin/category/create,添加分类
        echo 'create';
    }

    public function update(){
        //put来的 admin/category/{category},更新分类
        echo 'update';
    }

    public function destroy(){
        //delete来的admin/category/{category},删除单个分类
        echo 'destroy';
    }

    public function show(){
        //get来的admin/category/{category},显示单个分类信息
        echo 'show';
    }

    public function edit(){
        //get来的admin/category/{category}/edit
        echo 'edit';
    }


}
